home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
126-150
/
apd135
/
space maths.amos
/
space maths.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1990-08-11
|
6KB
|
212 lines
Screen Open 0,320,200,16,Lowres
Global LEVEL,NAME$,OP$,A,B,C,X,ANS,SCORE,XL,RN,RN1,GOES1,FLAG,K
TITLE
STAR:
GNAME
SMATHS
End
Procedure TITLE
Hide On
Load Iff "smaths/title.iff",1
Load "smaths/music.abk"
Load "smaths/sprites.abk"
Music 1
Pen 3 : Paper 0
Locate 12,15
Print "PRESS ANY KEY"
Wait Key
Music Stop
Load Iff "smaths/game.iff",1
End Proc
Procedure GNAME
'*************** GET ALL USER INFORMATION (NAME,AGE,NUMBER OF SUMS) *******
Say " "
Pen 15 : Paper 0
Locate 2,4 : Print "PLEASE PRINT"
Locate 2,6 : Print "YOUR NAME "
Locate 2,8 : Input NAME$
C$=Left$(NAME$,1)
C$=Upper$(C$)
Left$(NAME$,1)=C$
NAME$=NAME$+"."
TALK$="hello "+NAME$
Say TALK$
BLANK
AGAIN2:
Say "how old are you."
Locate 2,4 : Print "How old are"
Locate 2,6 : Print "you "
Locate 2,8 : Print " ";
Input AGE$ : HOTKEY[AGE$] : If FLAG=1 Then Goto AGAIN2
AGE=K
If AGE<6 Then LEVEL=1
If AGE>5 and AGE<9 Then LEVEL=2
If AGE>8 and AGE<13 Then LEVEL=3
If AGE>12 and AGE<16 Then LEVEL=4
If AGE>15 Then LEVEL=5
BLANK
AGAIN3:
Say "how many sums would you like. "
Locate 2,4 : Print "How many sums"
Locate 2,6 : Print "Do you want"
Locate 2,10 : Print " ";
Input GOES1$ : HOTKEY[GOES1$] : If FLAG=1 Then Goto AGAIN3
GOES1=K
End Proc
Procedure BLANK
'************************************************
'**************** ERASES THE BLACKBOARD *********
'************************************************
For Z=4 To 29
Locate 2,Z
Print " "
Next Z
End Proc
Procedure RANDOM
'************ Get a Random Operator ***************
Randomize Timer
OP$="" : X=0
While OP$=""
X=Rnd(3)+1
If X=1 Then OP$=" -"
If X=2 Then OP$=" +"
If X=3 and LEVEL>2 Then OP$=" *"
If X=4 and LEVEL>2 Then OP$=" /"
Wend
'
'********* Get RANDOM NUMBERS For SUMS ************
REP:
If LEVEL=1 Then A=Rnd(4)+1 : B=Rnd(4)+1
If LEVEL=2 Then A=Rnd(5)+5 : B=Rnd(5)+5
If LEVEL=3 Then A=Rnd(40)+10 : B=Rnd(40)+10
If LEVEL=4 Then A=Rnd(90)+10 : B=Rnd(90)+10
If LEVEL=5 Then A=Rnd(1000)+10 : B=Rnd(100)+10
If OP$=" -" and A<B Then Goto REP
If OP$=" /" Then DIV
End Proc
Procedure DIV
'**************** Routine to Ensure Number A is Divisable by number B without any remainder
AGAIN:
A=Rnd(143)+1 : B=Rnd(11)+1
D=A mod B
If D<>0 Then Goto AGAIN
End Proc
Procedure SCORE
'************************************************
'********** PRINT SCORE TO SCREEN ***************
'************************************************
Locate 2,29 : Print "SCORE ";SCORE
End Proc
Procedure SCORECHECK
'************************************************
'********* CHECKS SCORE FOR WHEN TO GET ALIEN ***
'************************************************
SCCH=SCORE mod RN1
If SCCH=0 Then RN=Rnd(200) : SHOT
End Proc
Procedure SMATHS
'*************************************************
'*********** MAIN MATHS ROUTINE ******************
'*************************************************
BLANK
SCORE=0 : RN1=5 : GOES=0 : Rem ****** RESETS GAME VARIABLES
BEG:
GOES=GOES+1 : If GOES=GOES1+1 Then FIN : Goto STAR
RANDOM
If X=1 Then C=A-B
If X=2 Then C=A+B
If X=3 Then C=A*B
If X=4 Then C=A/B
'************ PRINT SUMS TO SCREEN ****************
AGAIN1:
Locate 2,4
Print A;OP$;B
Locate 2,6
Print "What is the"
Locate 2,8
'**************************************************
Input "Answer = ";ANS$ : HOTKEY[ANS$] : If FLAG=1 Then Goto AGAIN1 : Rem *** IF NOT A NUMBER KEY PRESSED REPRINT SUM
If K=C Then Locate 2,10 : Print "CORRECT" : Wait 50 : BLANK : SCORE=SCORE+1 : SCORE : SCORECHECK : Goto BEG
Locate 2,16 : Print "THAT IS WRONG"
Locate 2,18 : Print "THE CORRECT "
Locate 2,20 : Print "ANSWER WAS::"
Locate 2,22 : Print " ";C
Locate 2,24 : Print "PRESS A KEY" : Wait Key : BLANK : Goto BEG :
End Proc
Procedure HOTKEY[K$]
'******************* ENSURES ONLY NUMBER KEYS ARE PRESSED ****************
FLAG=0
If Asc(K$)<48 or Asc(K$)>57 Then Locate 2,10 : BLANK : FLAG=1 : Rem****IF ANSWER ISN~T A NUMBER WAIT *****'
K=Val(K$) : Rem**** CHANGE STRING VARIABLE TO NUMBER VARIABLE FOR USE IN MAIN PROG (SMATHS)
End Proc[K]
Procedure SHOT
'***************************************************
'************** GRAPHICS GAME ****************
'***************************************************
Say "shoot the alien for extra bownus poynts. "
Hide On
Get Sprite Palette %11111111111111110000000000000000
Make Mask
XL=260 : SX=435 : SY=50 : DR=1 : Y=280 : L=3
REP1:
If Jleft(1) Then XL=XL-1
If Jright(1) Then XL=XL+1
Sprite 0,XL,280,1
If XL<260 Then XL=260
If XL>435 Then XL=435
Sprite 4,SX,SY,3
For COUNT=1 To RN : Next COUNT
If DR=1 Then Dec SX
If DR=0 Then Inc SX
If SX<261 Then DR=0
If SX>435 Then DR=1
If Fire(1)=-1 Then SARA=1 : Shoot
If SARA<>1 Then Goto REP1
Sprite 2,XL,Y,2
C=Sprite Col(4)
If C=-1 Then Boom : Sprite Off 2 : Sprite 4,XL,SY,4 : Wait 50 : Sprite Off 4 : SCORE=SCORE+10 : SCORE : Goto SKIP1
Dec Y
If Y<>26 Then Goto REP1
SKIP1:
SARA=0 : Y=280 : Dec L
If L<>0 Then Goto REP1
Sprite Off
RN1=Rnd(10)+5
End Proc
Procedure FIN
'************************************************
'******* GAME OVER AND START AGAIN ***********
'************************************************
BLANK
Locate 2,4 : Print "Your game"
Locate 2,6 : Print "Is over."
Locate 2,8 : Print "You answered"
Locate 2,10 : Print "";GOES1
Locate 2,12 : Print " Questions"
Locate 2,14 : Print "And scored"
Locate 2,16 : Print " ";SCORE
Locate 2,18 : Print "PRESS 'Y'"
Locate 2,20 : Print "TO PLAY AGAIN"
Locate 2,22 : Print "OR 'N' TO END"
Do
N=Key State(54) : If N=-1 Then End
Y=Key State(21) : If Y=-1 Then Exit
Loop
Clear Key
BLANK
End Proc
'
'*********************** VARIABLE LIST *****************
'NAME$
'AGE
'LEVEL
'op$ ****** Operator e.g. - + * /
'a ****** first number
'b ****** second
'c ****** correct answer
'ans ****** users answer
'scch ****** determines when to go to graphic game
'rn1 ****** determines when to go to graphic game also
'rn ****** holds s random speed factor for alien
'goes1 ****** holds how many goes you want
'goes ****** holds how many goes you've had